package com.example.test.controller;

import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.concurrent.atomic.AtomicInteger;

@RestController
@RequestMapping("/authentication")
public class AuthController extends BaseController {

    private static AtomicInteger num = new AtomicInteger(0);

    @PostMapping("form")
    public Object list(@RequestParam String type, HttpServletResponse httpResponse) {
        num.incrementAndGet();
        if ("0".equals(type)){
            return createSuccess();
        }else if ("1".equals(type)){
            httpResponse.setStatus(302);
            return createError();
        }else {
            return "缺少type参数";
        }
    }

    @RequestMapping(value = "getNum")
    public Integer getNum() {
        return num.get();
    }
}
